﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GreenPepper.Interpreters.Scenario;

namespace GreenPepperTest.Fixtures
{
    public class MotionDetectorTestFixture
    {
        private HomeSecuritySystem sys;

        [Given("I create new security system")]
        public void CreateNewSecuritySystem()
        {
            sys = new HomeSecuritySystem();
        }

        [Then ("Check the number of motion detectors in security system is ([0-9]+)")]
        public void NumberOfMotionDetectorsInSecuritySystem(Expectation expectation)
        {
            expectation.Actual = sys.GetNumberOfMotionDetectors();
        }

        [When("I add a new motion detector to the ([a-zA-Z ]+)")]
        public void AddNewMotionDetectorWithLocation(string loc)
        {
            MotionDetector mt = new MotionDetector(loc);
            sys.AddMotionDetector(mt);
        }

        [When("Create movement at ([a-z A-Z]+)")]
        public void CreateMovementAt(string loc)
        {
            sys.CreateMovementAt(loc);
        }

        [Check("Check ([a-z A-Z]+)'s alarm is on.")]
        public bool IsAlarmOnAt(string loc)
        {
            return sys.IsAlarmOn(loc);
        }

        [Check("Check ([a-z A-Z]+)'s alarm is off.")]
        public bool IsAlarmOffAt(string loc)
        {
            return !sys.IsAlarmOn(loc);
        }

        [Check("Check ([a-zA-Z]+)'s alarm hasn't been tripped.")]
        public bool IsAlarmNotTrippedAt(string loc)
        {
            if ("Platform2".Equals(System.Environment.GetEnvironmentVariable("ASPEN_PLATFORM")))
            {
                return false;
            }
            return !sys.IsAlarmTrippedAt(loc);
        }

        [Check("Check ([a-zA-Z]+)'s alarm has been tripped.")]
        public bool IsAlarmTrippedAt(string loc)
        {
            return sys.IsAlarmTrippedAt(loc);
        }

    }
}
